package com.yy.wga.pay.service.client.request.alipay;

import com.alibaba.fastjson.annotation.JSONField;
import com.yy.wga.pay.service.client.request.BaseRefundRequest;
import com.yy.wga.pay.service.client.response.alipay.AliPayRefundResponse;
import com.yy.wga.pay.service.client.request.BaseRefundRequest;
import com.yy.wga.pay.service.client.response.alipay.AliPayRefundResponse;
import com.yy.wga.pay.service.client.request.BaseRefundRequest;
import com.yy.wga.pay.service.client.response.alipay.AliPayRefundResponse;
import com.yy.wga.pay.service.client.request.BaseRefundRequest;
import com.yy.wga.pay.service.client.response.alipay.AliPayRefundResponse;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
* Created by gc on 2021/8/30.
*
* @author : gc
*
* Description: 支付宝退款接口请求参数
**/
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class AliPayRefundRequest extends BaseRefundRequest<AliPayRefundResponse> {

    private static final long serialVersionUID = -7027487347217226590L;

    /**
     * 应用id
     */
    private String appId;

    /**
     * 商户订单号
     */
    @JSONField(name = "out_trade_no")
    private String outTradeNo;

    /**
     * 支付宝交易号
     */
    @JSONField(name = "trade_no")
    private String tradeNo;

    /**
     * 退款金额，单位为元，支持两位小数
     */
    @JSONField(name = "refund_amount")
    @NotBlank(message = "退款金额不能为空")
    private String refundAmount;

    /**
     * 退款原因说明
     */
    @JSONField(name = "refund_reason")
    private String refundReason;

    /**
     * 退款请求号，如需部分退款，则此参数必传
     */
    @JSONField(name = "out_request_no")
    private String outRequestNo;

    /**
     * 退款包含的商品列表信息
     */
    @JSONField(name = "refund_goods_detail")
    private List<RefundGoodsDetail> refundGoodsDetail;

    /**
     * 退分账明细信息
     */
    @JSONField(name = "refund_royalty_parameters")
    private List<RefundRoyaltyParameters> refundRoyaltyParameters;

    /**
     * 查询选项。refund_detail_item_list：退款使用的资金渠道；deposit_back_info：触发银行卡冲退信息通知
     */
    @JSONField(name = "query_options")
    private List<String> queryOptions;

    @Data
    public static class RefundGoodsDetail {

        /**
         * 商品编号
         */
        @JSONField(name = "goods_id")
        @NotBlank
        private String goodsId;

        /**
         * 退款金额，单位为元，支持两位小数
         */
        @JSONField(name = "refund_amount")
        @NotNull(message = "退款金额不能为空")
        private String refundAmount;

        /**
         * 商家侧小程序商品ID
         */
        @JSONField(name = "out_item_id")
        private String outItemId;

        /**
         * 商家侧小程序商品ID
         */
        @JSONField(name = "out_sku_id")
        private String outSkuId;
    }

    @Data
    public static class RefundRoyaltyParameters {

        /**
         * 分账类型.普通分账为：transfer;补差为：replenish;为空默认为分账transfer;
         */
        @JSONField(name = "royalty_type")
        private String royaltyType;

        /**
         * 支出方账户
         */
        @JSONField(name = "trans_out")
        private String transOut;

        /**
         * 支出方账户类型，userId表示是支付宝账号对应的支付宝唯一用户号，loginName表示是支付宝登录号
         */
        @JSONField(name = "trans_out_type")
        private String trans_outType;

        /**
         * 收入方账户类型。userId表示是支付宝账号对应的支付宝唯一用户号;cardAliasNo表示是卡编号;loginName表示是支付宝登录号；
         */
        @JSONField(name = "trans_in_type")
        private String transInType;

        /**
         * 收入方账户
         */
        @JSONField(name = "trans_in")
        @NotBlank
        private String transIn;

        /**
         * 分账的金额，单位为元
         */
        @JSONField(name = "amount")
        private String amount;

        /**
         * 分账描述
         */
        @JSONField(name = "desc")
        private String desc;

        /**
         * 可选值：达人佣金、平台服务费、技术服务费、其他
         */
        @JSONField(name = "royalty_scene")
        private String royaltyScene;

        /**
         * 分账收款方姓名
         */
        @JSONField(name = "trans_in_name")
        private String transInName;
    }
}
